function lambdaprime = lambdaprimes(AA,lambda,NN)
%Calculates hazard function of cumulative price changes using the first
%adjustment
%Inputs:        AA: n x n transition matrix
%               lambda: n x 1 contemporaneous hazard function
%               NN: number of periods over which price changes are cumulated

%Output:        lambdaprime: cumulative hazard function

nn = length(lambda);

iterMatr = eye(nn);
Lambda = diag(lambda);

for ii=2:NN
    iterMatr = eye(nn) + iterMatr*(eye(nn)-Lambda)*AA;
end

lambdaprime = AA*iterMatr*lambda;